/*
 * RT MAP, Home of Professional MAP
 * Copyright 2021 Bit Main Inc. and/or its affiliates and other contributors
 * as indicated by the @author tags. All rights reserved.
 * See the copyright.txt in the distribution for a
 * full listing of individual contributors.
 */
package com.rw.map.model;

/**
 * @author CaoYuyao
 * @title Point
 * @description 道路节点
 * @date 2021/9/10
 */
public class Point implements Cloneable {
    //使用该id进行计算
    String id;
    String camera;
    double x;
    double y;
    /**
     * 偏移后的X
     */
    double offsetX;
    /**
     * 偏移后的Y
     */
    double offsetY;

    public Point(String id, String camera, double x, double y) {
        this.id = id;
        this.camera = camera;
        this.x = x;
        this.y = y;
    }

    /**
     * 增加随机抖动
     */
    public void setRandomOffset(double offset) {
        this.offsetX = (Math.round((this.x + Math.random() * offset - offset / 2) * 100) / 100.0);
        this.offsetY = (Math.round((this.y + Math.random() * offset - offset / 2) * 100) / 100.0);
    }

    @Override
    public String toString() {
        return "Point{" +
                "id='" + id + '\'' +
                ", camera='" + camera + '\'' +
                ", x=" + x +
                ", y=" + y +
                ", offsetX=" + offsetX +
                ", offsetY=" + offsetY +
                '}';
    }

    /**
     * 增加-3到3的随机抖动
     */
    public void setRandomOffset() {
        this.setRandomOffset(6);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getCamera() {
        return camera;
    }

    public void setCamera(String camera) {
        this.camera = camera;
    }

    public double getX() {
        return x;
    }

    public void setX(double x) {
        this.x = x;
    }

    public double getY() {
        return y;
    }

    public void setY(double y) {
        this.y = y;
    }

    public double getOffsetX() {
        return offsetX;
    }

    public void setOffsetX(double offsetX) {
        this.offsetX = offsetX;
    }

    public double getOffsetY() {
        return offsetY;
    }

    public void setOffsetY(double offsetY) {
        this.offsetY = offsetY;
    }

    @Override
    public Point clone() throws CloneNotSupportedException {
         return (Point) super.clone();
    }
}
